Path: blob/master/Part 4 - Clustering/K-Means Clustering/[Python] K-Means Clustering.ipynb
1009 views
Kernel: Python 3
K-Means Clustering
Data preprocessing
In [1]:
In [2]:
In [3]:
Out[3]:
array([[15, 39],
[15, 81],
[16, 6],
[16, 77],
[17, 40],
[17, 76],
[18, 6],
[18, 94],
[19, 3],
[19, 72]])
Using the elbow method to find the optimal number of clusters
In [4]:
In [5]:
In [6]:
Out[6]:
From the Elbow method we can see that the optimal cluster number is 5 for the given dataset
Applying K-Means to the Mall dataset
In [7]:
Visualizing the clusters
In [8]:
Out[8]:
<matplotlib.legend.Legend at 0x7f402e5c81d0>
The target customers should be the one with High Earning and High Spend.
In [ ]: